
#include <stdio.h>

struct LispFuncCachedAddress {
    long ver;
    void * addr;
};

struct LispObject {
    int type_tag;
};

struct LispArguments {
    struct LispObject * args;
    unsigned int count;
};

struct LispFuncTableEntry {
    struct LispFuncTableEntry * next;
    char name[1];
};

struct LispFuncTable {
    unsigned int size;
    struct LispFuncTableEntry * arr;
};


// easy serializable entities

// Lisp Base Object
struct SALEntity {
    int type_tag;
};

// Lisp CDR
struct SALCdr {
    struct SALEntity parent;

    int car_ref_idx;
    int cdr_ref_idx;
};

// Storage Environment
struct SALStorageEnv {
    char * buffer;
    int size;
};


struct SALCdr *
sal_util_cdr(struct SALStorageEnv * env, struct SALCdr * cdr) {
    if (cdr->cdr_ref_idx < 0 || cdr->cdr_ref_idx >= env->size) {
	// TODO: error
    }

    return (struct SALCdr *)(env->buffer + cdr->cdr_ref_idx);
}


/**
 * Calls lisp function given
 * @return status value, zero indicates success, negative value indicates error
 */
int lisp_func_call(struct LispFuncCachedAddress * cached_addr,
		   const char * func_name,
		   struct LispArguments * args,
		   struct LispObject ** return_value) {
    return -1;
}

int main(int argc, char * argv[]) {
    fputs("this is a test\n", stderr);
    return 0;
}
